@extends('admin.adminbase')
@section('content')
    <section class="hbox stretch">
        @include("admin.public.left")
        <aside>
            <section class="vbox">

                <header class="header bg-white b-b clearfix">
                    <form class="talbe-search" method="get" action="">
                        <div class="row m-t-sm">
                            <div class="col-sm-12 m-b-xs">
                                <div class="btn-group" role="group">
                                    <strong style="line-height:30px;">旅游卡核销</strong>
                                </div>
                                <div class="btn-group pull-right">
                                    <a role="button" class="btn btn-info btn-sm " title="返回" onclick="history.back()">
                                        <i class="glyphicon glyphicon-arrow-left"></i>&nbsp;返回
                                    </a>
                                </div>
                            </div>
                        </div>
                    </form>
                </header>
                <section class="scrollable  wrapper w-f">
                    <section class="panel panel-default ">
                        <div class="row m-l-none m-r-none bg-light lter">
                            <div class="container" style="padding: 20px 0px">
                                <form id="formclass" class="form-horizontal" style="padding-top: 15px;">
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">景区</label>
                                        <div class="col-sm-4 ">

                                            <select id="region_id" class="input-sm">
                                                <option value="0">选择省份</option>
                                                @foreach($parent as $v)
                                                    <option value="{{ $v->id }}">{{ $v->name }}</option>
                                                @endforeach
                                            </select>
                                            <select id="region_id2" class="input-sm">
                                            </select>
                                            <select id="scenery" class="input-sm" name="scenery_id" required>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">卡号</label>
                                        <div class="col-sm-4 ">
                                            <input type="text" class="form-control" name="card_num" required
                                                   placeholder="请输入卡号">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label">密码</label>
                                        <div class="col-sm-4 ">
                                            <input type="text" class="form-control" name="password" required
                                                   placeholder="请输入密码">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-3 control-label"></label>
                                        <div class="col-sm-2 ">
                                            <button role="button" class="btn btn-default" addparm="" type="submit">提交</button>
                                            <input type="checkbox" id="back">
                                            <label for="back">返回列表</label>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>

                    </section>
                </section>


            </section>
        </aside>
    </section>
@endsection
@section('addscript')
    <script>
        $(function(){
            //二级联动
            $("#region_id").change(function() {
                var first = $(this).val();
                $.post("{{ url('admin/scenery/pull') }}",{pid:first},function(data){
                    if(data) {
                        var region_id2 = $("#region_id2");
                        $("option", region_id2).remove();
                        region_id2.append("<option value='0'>选择城市</option>");
                        $.each(data, function (index, array) {
                            var option = "<option value='" + array['id'] + "'>" + array['name'] + "</option>";
                            region_id2.append(option);
                        });
                    }
                });
            });

            //三级下拉
            $("#region_id2").change(function() {
                var secend = $(this).val();
                $.post("{{ url('admin/verify/pull') }}",{rid:secend},function(data) {
                    if (data) {
                        var scenery = $("#scenery");
                        $("option", scenery).remove();
                        $.each(data, function (index, array) {
                            var item = "<option value='" + array['id'] + "'>" + array['name'] + "</option>";
                            scenery.append(item);
                        });
                    }
                });
            });

            //提交表单
            $("#formclass").submit(function(){
                var data = $(this).serialize();
                $.post("{{ url('admin/verify/create') }}",data,function(data){
                    if(data.success){
                        layer.alert(data.data,function(){
                            location.reload();
                        })
                    }else {
                        layer.alert(data.data);
                    }
                });
                return false;
            })


        });
    </script>
@endsection
